package com.health.controller;

import com.health.pojo.ComboForm;
import com.health.pojo.Users;
import com.health.service.DeleteOrderService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(name = "DeleteOrderServlet", value = "/DeleteOrderServlet")
public class DeleteOrderServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("UTF-8");

        Users user = (Users) request.getSession().getAttribute("user");
        DeleteOrderService deleteOrderService = new DeleteOrderService();
        ArrayList<ComboForm> comboForms = new ArrayList<ComboForm>();

        int servicetype = 1;//获取服务类型
        String type = request.getParameter("serviceType");
        if (type != null) {
            servicetype = Integer.parseInt(type);
        }
        int examine_id = 0;
        String eid = request.getParameter("eid");
        if (eid != null) {
            examine_id = Integer.parseInt(eid);
        }
        String datetime = "";
        String time = request.getParameter("time");
        if (time != "unfined") {
            datetime = time;
        }
        deleteOrderService.dispath(servicetype, user.getUserId(), examine_id, datetime, comboForms);//user.getUserId()
        // int i;
        // for (i=1;i<5;i++){
        //System.out.println(comboForms.get(i).toString());
        // }
        request.getSession().setAttribute("comboForms", comboForms);
        // 设置aside侧边栏状态
        request.setAttribute("asideStatus", 4);
        // 转发视图
        request.getRequestDispatcher("restrictedPages/main.jsp").forward(request, response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
